﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Macds.Core.Configuration;

namespace Macds.Core.IoC
{
    public class PropertyElement : ConfigurationElement
    {
        [ConfigurationProperty("name", IsRequired = true)]
        public String Name
        {
            get { return (String)this["name"]; }
            set { this["name"] = value; }
        }

        [ConfigurationProperty("object", IsRequired = false)]
        public String Object
        {
            get { return (String)this["object"]; }
            set { this["object"] = value; }
        }

        [ConfigurationProperty("value", IsRequired = false)]
        public String Value
        {
            get 
            {
                return (String)this["value"]; 
            }
            set { this["value"] = value; }
        }

        [ConfigurationProperty("single", IsRequired = false, DefaultValue = true)]
        public bool Single
        {
            get { return (bool)this["single"]; }
            set { this["single"] = value; }
        }

        [ConfigurationProperty("valueType", IsRequired = false, DefaultValue = "")]
        public String ValueType
        {
            get { return (String)this["valueType"]; }
            set { this["valueType"] = value; }
        }

        [ConfigurationProperty("items", IsRequired = false),
        ConfigurationCollection(typeof(GenericElementCollection<ItemElement>), AddItemName = "item", ClearItemsName = "clear", RemoveItemName = "remove")]
        public GenericElementCollection<ItemElement> Items
        {
            get { return (GenericElementCollection<ItemElement>)this["items"]; }
            set { this["items"] = value; }
        }

        [ConfigurationProperty("values", IsRequired = false),
        ConfigurationCollection(typeof(GenericElementCollection<ItemElement>), AddItemName = "value", ClearItemsName = "clear", RemoveItemName = "remove")]
        public GenericElementCollection<ValueElement> Values
        {
            get { return (GenericElementCollection<ValueElement>)this["values"]; }
            set { this["values"] = value; }
        }

        public override string ToString()
        {
            return Name.ToString();
        }
    }
}
